package Utility;

/**
 *
 * @author Apolloz
 */
public class CardUtils {

    public static byte getCardValue(byte card) {
        return (byte) (card >> 2);
    }

    public static String cardsToString(byte[] cards) {
        String result = "";
        for (int j = 0; j < cards.length; j++) {
            String num;
            char suit;
            switch (cards[j] / 4) {
                case 10:
                    num = "10";
                    break;
                case 11:
                    num = "J";
                    break;
                case 12:
                    num = "Q";
                    break;
                case 13:
                    num = "K";
                    break;
                case 14:
                    num = "A";
                    break;
                case 15:
                    num = "2";
                    break;
                default:
                    num = "" + (char) ('0' + cards[j] / 4);
            }
            switch (cards[j] % 4) {
//                    case 0: suit = '♠'; break;
//                    case 1: suit = '♣'; break;
//                    case 2: suit = '♦'; break;
//                    case 3: suit = '♥'; break;
                case 0:
                    suit = 'B';
                    break;
                case 1:
                    suit = 'c';
                    break;
                case 2:
                    suit = 'R';
                    break;
                case 3:
                    suit = 'C';
                    break;
                default:
                    suit = ' ';
            }
            result += (num) + suit + " ";
        }
        return result;
    }

//    public static String bonesToString(byte[] bones) {
//        String result = "";
//        for (int i = 0; i < bones.length; i++) {
//            byte value1 = DominoLogic.getFirstValue(bones[i]);
//            byte value2 = DominoLogic.getSecondValue(bones[i]);
//            result += value1 + "-" + value2 + " ";
//        }
//        return result;
//    }

    public static String shipCoordinatesToString(byte[] shipCoordinates) {
        String result = "";
        for (int i = 0; i < shipCoordinates.length; i++) {
            int value1 = shipCoordinates[i] / 10 + 1;
            int value2 = shipCoordinates[i] % 10;
            result += "[" + value1 + "|" + value2 + "] ";
        }
        return result;
    }

    public static String getLogGameString(int maxPlayer) {
        String result = "";
        for (int i = 0; i < maxPlayer; i++) {
            result += "player" + (i+1) + ",player" + (i+1)+ "_card,";
        }
        return result;
    }
}
